#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 5007

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["netcore_api/netcore_api.csproj", "netcore_api/"]
COPY ["netcore_service/netcore_service.csproj", "netcore_service/"]
COPY ["netcore_comm/netcore_comm.csproj", "netcore_comm/"]
RUN dotnet restore "netcore_api/netcore_api.csproj"
COPY . .
WORKDIR "/src/netcore_api"
RUN dotnet build "netcore_api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "netcore_api.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list
RUN apt-get update -y && apt-get install -y libgdiplus && apt-get clean && ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll

ENTRYPOINT ["dotnet", "netcore_api.dll"]